﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FlowDesigner.Loadinganimation
{
    public class LoadingBase
    {
        private readonly Loading loading;
        public LoadingBase(Loading loading)
        {
            this.loading = loading;
        }
        private bool IsopenLoading_;

        public bool IsopenLoading
        {
            get { return IsopenLoading_; }
            set { IsopenLoading_ = value;
                if(value&& loading.IsVisible==false)
                {
                    try
                    {
                        loading.Owner = App.Current.MainWindow;
                        loading.Show();
                    }
                    catch
                    {
                        loading.Close();
                    }
                }
                else
                {
                    if (loading.IsVisible)
                    {
                        try
                        {
                            loading.Close();
                        }
                        catch
                        {
                            loading.Close();
                        }
                    }
                }
            
            }
        }
    }
}
